package com.spic.business.ioc.controller;

import com.spic.business.ioc.domain.IocNoiseData;
import com.spic.business.ioc.service.IIocNoiseDataService;
import com.spic.common.core.utils.poi.ExcelUtil;
import com.spic.common.core.web.controller.BaseController;
import com.spic.common.core.web.domain.AjaxResult;
import com.spic.common.core.web.page.TableDataInfo;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import javax.servlet.http.HttpServletResponse;
import java.io.IOException;
import java.util.List;

/**
 * 噪声数据Controller
 *
 * @author spic
 * @date 2022-04-14
 */
@RestController
@RequestMapping("/ioc/data")
public class IocNoiseDataController extends BaseController
{
    @Autowired
    private IIocNoiseDataService iocNoiseDataService;

    /**
     * 查询噪声数据列表
     */
//    @PreAuthorize(hasPermi = "ioc:data:list")
    @GetMapping("/list")
    public TableDataInfo list(IocNoiseData iocNoiseData)
    {
        startPage();
        List<IocNoiseData> list = iocNoiseDataService.selectIocNoiseDataList(iocNoiseData);
        return getDataTable(list);
    }

    /**
     * 导出噪声数据列表
     */
//    @PreAuthorize(hasPermi = "ioc:data:export")
//    @Log(title = "噪声数据", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, IocNoiseData iocNoiseData) throws IOException
    {
        List<IocNoiseData> list = iocNoiseDataService.selectIocNoiseDataList(iocNoiseData);
        ExcelUtil<IocNoiseData> util = new ExcelUtil<IocNoiseData>(IocNoiseData.class);
        util.exportExcel(response, list, "噪声数据数据");
    }

    /**
     * 获取噪声数据详细信息
     */
//    @PreAuthorize(hasPermi = "ioc:data:query")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") String id)
    {
        return AjaxResult.success(iocNoiseDataService.selectIocNoiseDataById(id));
    }

    /**
     * 新增噪声数据
     */
//    @PreAuthorize(hasPermi = "ioc:data:add")
//    @Log(title = "噪声数据", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody IocNoiseData iocNoiseData)
    {
        return toAjax(iocNoiseDataService.insertIocNoiseData(iocNoiseData));
    }

    /**
     * 修改噪声数据
     */
//    @PreAuthorize(hasPermi = "ioc:data:edit")
//    @Log(title = "噪声数据", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody IocNoiseData iocNoiseData)
    {
        return toAjax(iocNoiseDataService.updateIocNoiseData(iocNoiseData));
    }

    /**
     * 删除噪声数据
     */
//    @PreAuthorize(hasPermi = "ioc:data:remove")
//    @Log(title = "噪声数据", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable String[] ids)
    {
        return toAjax(iocNoiseDataService.deleteIocNoiseDataByIds(ids));
    }
}
